USE MASTER
GO
IF EXISTS(SELECT name FROM sys.databases WHERE name=N'ManageATM')
DROP DATABASE ManageATM
GO

CREATE DATABASE ManageATM
GO

USE ManageATM

CREATE TABLE Account(
	
	Ip nvarchar(10)  primary key,
	Pin nvarchar(10) not null,
	Name nvarchar(30)not null,
	TimeCreate datetime not null,
	Balance int
)
go
CREATE TABLE [Transaction](
	id int identity(1,1) primary key,
	IpFrom nvarchar(10),
	IpTo nvarchar(10),
	[Type] nvarchar(50),
	Amount money,
	Balance money,
	[Description] nvarchar(200),
	[time] datetime
)
go
ALTER TABLE [Transaction]
ADD FOREIGN KEY (IpFrom) REFERENCES Account(Ip);

INSERT INTO Account values('19008198','11111','Chungnd','12/12/2012','150000000')
INSERT INTO Account values('19008199','22222','Anhntv','01/10/2010','170000000')
INSERT INTO Account values('19008197','33333','Longdt','10/11/2011','100000000')


--INSERT INTO SendingAccount values('19008198','19008199','Transfer''5000','12/12/2013')
--INSERT INTO SendingAccount values('19008199','19008197','10000','10/12/2013')
--INSERT INTO SendingAccount values('19008198','19008199','5000','12/12/2013')
select*from Account
select * from [Transaction]